<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增规格')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <div class="tabs-container">
              <ul class="nav nav-tabs">
                  <li class="active">
                     <a data-toggle="tab" href="#specTab" aria-expanded="true">商品规格</a>
                  </li>
                  <!--
                  <li class="">
                     <a data-toggle="tab" href="#paramTab" aria-expanded="false">商品参数</a>
                  </li>
				  -->
              </ul>
                    <div class="tab-content">
                        <div id="specTab" class="tab-pane active">
                            <div class="panel-body">
                                    <form class="form-horizontal m" id="form-spec-add">
                                        <input name="attrType" class="form-control" type="hidden" value="0">
							            <div class="form-group">    
							                <label class="col-sm-3 control-label is-required">规格名称：</label>
							                <div class="col-sm-8">
							                    <input name="attrName" class="form-control" type="text" required>
							                </div>
							            </div>
							            <div class="form-group">    
							                <label class="col-sm-3 control-label is-required">选项值(多值以","分隔)：</label>
							                <div class="col-sm-8">
							                    <input name="attrValues" class="form-control" type="text" required>
							                </div>
							            </div>
							            <div class="form-group">    
							                <label class="col-sm-3 control-label is-required">排序号：</label>
							                <div class="col-sm-8">
							                    <input name="sort" class="form-control" type="text" required>
							                </div>
							            </div>
							        </form>
                            </div>
                        </div>
                        <!--
                        <div id="paramTab" class="tab-pane">
                            <div class="panel-body">
                                    <form class="form-horizontal m" id="form-param-add">
                                        <input name="attrType" class="form-control" type="hidden" value="1">
							            <div class="form-group">    
							                <label class="col-sm-3 control-label is-required">参数名称：</label>
							                <div class="col-sm-8">
							                    <input name="attrName" class="form-control" type="text" required>
							                </div>
							            </div>
							            <div class="form-group">    
							                <label class="col-sm-3 control-label is-required">输入类型：</label>
							                <div class="col-sm-8">
												<select name="inputType" class="form-control" th:with="type=${@dict.getType('shop_input_type')}">
									                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
									            </select>
							                </div>
							            </div>
							            <div class="form-group">    
							                <label class="col-sm-3 control-label">选项值(多值以","分隔)：</label>
							                <div class="col-sm-8">
							                    <input name="attrValues" class="form-control" type="text" >
							                </div>
							            </div>
							            <div class="form-group">    
							                <label class="col-sm-3 control-label is-required">排序号：</label>
							                <div class="col-sm-8">
							                    <input name="sort" class="form-control" type="text" required>
							                </div>
							            </div>
							        </form>
                            </div>
                        </div>
                        -->
                  </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "shop/attr"
        var activeTab = "#specTab";
        $("#form-spec-add").validate({
            focusCleanup: true,
            onkeyup: false,
			rules:{
				sort:{
					digits:true
				}
			}
        });
        $("#form-param-add").validate({
            focusCleanup: true,
            onkeyup: false,
			rules:{
				sort:{
					digits:true
				}
			}
        });
        
        $(document).ready(function(){
            $('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
            	activeTab = $(e.target).attr('href') ;
            });
        });

        function submitHandler() {
        	if(activeTab == "#paramTab"){
        		if ($.validate.form("form-param-add")) {
        		    $.operate.save(prefix + "/add", $('#form-param-add').serialize());
                }
        	}else{
        		if ($.validate.form("form-spec-add")) {
        			$.operate.save(prefix + "/add", $('#form-spec-add').serialize());
                }
        	}
        }
    </script>
</body>
</html>